package com.xf.lastmall.service.impl;


import com.xf.lastmall.moudle.entity.OrderDetailEntity;
import com.xf.lastmall.moudle.entity.OrderRefundEntity;
import com.xf.lastmall.repository.OrderDetailRepository;
import com.xf.lastmall.repository.OrderRefundRepository;
import com.xf.lastmall.service.OrderDetailService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by wangzhaoqian5 on 2018/6/6.
 */
@Slf4j
@Service
public class OrderDetailServiceImpl implements OrderDetailService {

    @Resource
    private OrderDetailRepository orderDetailRepository;

    @Resource
    private OrderRefundRepository orderRefundRepository;


    @Override
    public List<OrderDetailEntity> findAllSubOrderByOrderNo(String orderNo) {
        return orderDetailRepository.findByOrderNo(orderNo);
    }

    @Override
    public int updateAndSaveDetailForRefund(String orderSubNo, int numb, OrderRefundEntity orderRefundEntity) {
        int i = 0;
        if (orderDetailRepository.updateRefundNum(orderSubNo, numb) > 0) {
            orderRefundRepository.save(orderRefundEntity);
        }
        return i;
    }

}
